﻿#include "TouchPoint.h"

TouchPoint::TouchPoint()
    : m_x(0)
    , m_y(0)
    , m_state(QTouchPointState::TouchPointReleased)
    , m_id(-1)
    , m_valid(false)
{

}

TouchPoint::TouchPoint(int px, int py, QTouchPointState ps, uint8_t pid, bool valid)
    : m_x(px)
    , m_y(py)
    , m_state(ps)
    , m_id(pid)
    , m_valid(valid)
{

}

int TouchPoint::x() const
{
    return m_x;
}

int TouchPoint::y() const
{
    return m_y;
}

QPoint TouchPoint::pos() const
{
    return QPoint(m_x, m_y);
}

QTouchPointState TouchPoint::state() const
{
    return m_state;
}

int8_t TouchPoint::id() const
{
    return m_id;
}

bool TouchPoint::isValid() const
{
    return m_valid;
}

QString TouchPoint::toString() const
{
    if (m_valid) {
        return QString("(%1, %2)").arg(m_x, 4).arg(m_y, 4);
    } else {
        return "(____, ____)";
    }
}

void TouchPoint::setPos(int px, int py)
{
    m_x = px;
    m_y = py;
}

void TouchPoint::setPos(const QPoint &pos)
{
    setPos(pos.x(), pos.y());
}

void TouchPoint::setState(QTouchPointState ps)
{
    m_state = ps;
}

void TouchPoint::setId(int8_t pid)
{
    m_id = pid;
}

void TouchPoint::setValid(bool valid)
{
    m_valid = valid;
}
